/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('antirisk', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model GetRealTimeRiskInfoRequest {
  atoken?: string(name='atoken', description='This parameter is required.', example='Ab63aqUKx9TmYRhPV7LnRLybLRQOEG6GQsr-oGlT8bo6-_z_oYxTqqutBz6R0dBognMN1DBvZImDadsKb8k_Hfcj8A8nrXtxch_nKVg5xARkRmMU2SU='),
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='62c792d188ccdf4b7ec1aa38'),
  extra?: string(name='extra', example='360risk'),
}

model GetRealTimeRiskInfoResponseBody = {
  msg?: string(name='Msg'),
  code?: long(name='code', example='200'),
  data?: {
    appChannel?: string(name='appChannel', example='360market'),
    fakeDevice?: string(name='fakeDevice', example='1'),
    idfa?: string(name='idfa', example='00000000-0000-0000-0000-000000000000'),
    oaid?: string(name='oaid', example='sf58rw7erdfdgdgseeg2434'),
    proxyDevice?: string(name='proxyDevice', example='0'),
    riskLevel?: string(name='riskLevel', example='RISK'),
    riskScore?: string(name='riskScore', example='60'),
    zid?: string(name='zid', example='815E045B-4A9E-AA76-BEFF-048C9B9F651A'),
  }(name='data'),
  requestId?: string(name='requestId', description='requestId', example='2343535353DF8984565'),
  success?: boolean(name='success', example='true'),
}

model GetRealTimeRiskInfoResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetRealTimeRiskInfoResponseBody(name='body'),
}

/**
 * @summary 获取实时反作弊信息
 *
 * @param request GetRealTimeRiskInfoRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetRealTimeRiskInfoResponse
 */
async function getRealTimeRiskInfoWithOptions(request: GetRealTimeRiskInfoRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetRealTimeRiskInfoResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.atoken)) {
    query['atoken'] = request.atoken;
  }
  if (!Util.isUnset(request.dataSourceId)) {
    query['dataSourceId'] = request.dataSourceId;
  }
  if (!Util.isUnset(request.extra)) {
    query['extra'] = request.extra;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetRealTimeRiskInfo',
    version = '2022-11-28',
    protocol = 'HTTPS',
    pathname = `/anti/getRealTimeRiskInfo`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 获取实时反作弊信息
 *
 * @param request GetRealTimeRiskInfoRequest
 * @return GetRealTimeRiskInfoResponse
 */
async function getRealTimeRiskInfo(request: GetRealTimeRiskInfoRequest): GetRealTimeRiskInfoResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getRealTimeRiskInfoWithOptions(request, headers, runtime);
}

model GetZidTagByAtokenRequest {
  atoken?: string(name='atoken', description='atoken

This parameter is required.', example='AcNh1pZFEJ9wEO1RkqK2S9Qt0DHxZR6riGmx4CpGrxCpf3_LxvQNQQGaLjGWRg_-Un1yC47qfEiwRysoCJgQrBSa7b274rzhuIW4QDer7J41X18PiHI='),
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='59892ebcaed179694b000104'),
}

model GetZidTagByAtokenResponseBody = {
  msg?: string(name='Msg'),
  code?: long(name='code', description='code', example='200'),
  data?: {
    aHook?: string(name='aHook', description='aHook', example='1'),
    debug?: string(name='debug', example='1'),
    doubleOpen?: string(name='doubleOpen', example='0'),
    javaHook?: string(name='javaHook', description='javaHook', example='1'),
    nativeHook?: string(name='nativeHook', example='1'),
    root?: string(name='root', example='1'),
    simulator?: string(name='simulator', example='1'),
    vpnProxy?: string(name='vpnProxy', example='0'),
    wifiProxy?: string(name='wifiProxy', example='1'),
    zid?: string(name='zid', example='F6DD4AD2-B7B8-AA3A-34B8-EDE55FC82FC6'),
  }(name='data'),
  requestId?: string(name='requestId', example='2343535353DF8984565'),
  success?: boolean(name='success', description='success', example='true'),
}

model GetZidTagByAtokenResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetZidTagByAtokenResponseBody(name='body'),
}

/**
 * @summary atoken换zid+tags
 *
 * @param request GetZidTagByAtokenRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetZidTagByAtokenResponse
 */
async function getZidTagByAtokenWithOptions(request: GetZidTagByAtokenRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetZidTagByAtokenResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.atoken)) {
    query['atoken'] = request.atoken;
  }
  if (!Util.isUnset(request.dataSourceId)) {
    query['dataSourceId'] = request.dataSourceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetZidTagByAtoken',
    version = '2022-11-28',
    protocol = 'HTTPS',
    pathname = `/anti/getZidTagByAtoken`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary atoken换zid+tags
 *
 * @param request GetZidTagByAtokenRequest
 * @return GetZidTagByAtokenResponse
 */
async function getZidTagByAtoken(request: GetZidTagByAtokenRequest): GetZidTagByAtokenResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getZidTagByAtokenWithOptions(request, headers, runtime);
}

model GetZidTagScoreByAtokenRequest {
  atoken?: string(name='atoken', description='atoken

This parameter is required.', example='AcNh1pZFEJ9wEO1RkqK2S9Qt0DHxZR6riGmx4CpGrxCpf3_LxvQNQQGaLjGWRg_-Un1yC47qfEiwRysoCJgQrBSa7b274rzhuIW4QDer7J41X18PiHI='),
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='59892ebcaed179694b000104'),
}

model GetZidTagScoreByAtokenResponseBody = {
  code?: long(name='Code', description='code', example='OK'),
  msg?: string(name='Msg'),
  data?: {
    aHook?: string(name='aHook', description='aHook', example='0'),
    debug?: string(name='debug', example='1'),
    doubleOpen?: string(name='doubleOpen', example='1'),
    javaHook?: string(name='javaHook', description='javaHook', example='0'),
    nativeHook?: string(name='nativeHook', example='0'),
    riskLevel?: string(name='riskLevel', example='RISK'),
    riskScore?: string(name='riskScore', example='60'),
    root?: string(name='root', example='0'),
    simulator?: string(name='simulator', example='1'),
    vpnProxy?: string(name='vpnProxy', example='0'),
    wifiProxy?: string(name='wifiProxy', example='0'),
    zid?: string(name='zid', example='F6DD4AD2-B7B8-AA3A-34B8-EDE55FC82FC6'),
  }(name='data'),
  requestId?: string(name='requestId', description='requestId', example='2343535353DF8984565'),
  success?: boolean(name='success', description='success', example='true'),
}

model GetZidTagScoreByAtokenResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetZidTagScoreByAtokenResponseBody(name='body'),
}

/**
 * @summary atoken换zid+tags+风险分
 *
 * @param request GetZidTagScoreByAtokenRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetZidTagScoreByAtokenResponse
 */
async function getZidTagScoreByAtokenWithOptions(request: GetZidTagScoreByAtokenRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetZidTagScoreByAtokenResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.atoken)) {
    query['atoken'] = request.atoken;
  }
  if (!Util.isUnset(request.dataSourceId)) {
    query['dataSourceId'] = request.dataSourceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetZidTagScoreByAtoken',
    version = '2022-11-28',
    protocol = 'HTTPS',
    pathname = `/anti/getZidTagScoreByAtoken`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary atoken换zid+tags+风险分
 *
 * @param request GetZidTagScoreByAtokenRequest
 * @return GetZidTagScoreByAtokenResponse
 */
async function getZidTagScoreByAtoken(request: GetZidTagScoreByAtokenRequest): GetZidTagScoreByAtokenResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getZidTagScoreByAtokenWithOptions(request, headers, runtime);
}

model ListChannelRiskDetailsRequest {
  channel?: string(name='channel', example='360market'),
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='59892ebcaed179694b000104'),
  end?: string(name='end', description='This parameter is required.', example='20230418'),
  isAllChannel?: string(name='isAllChannel', example='1'),
  start?: string(name='start', description='This parameter is required.', example='20230418'),
}

model ListChannelRiskDetailsResponseBody = {
  msg?: string(name='Msg'),
  code?: long(name='code', example='200'),
  data?: {
    riskDetails?: [ 
      {
        an?: string(name='an', example='0'),
        av?: string(name='av', example='v1.1.0'),
        bn?: string(name='bn', example='1'),
        c?: string(name='c', example='360market'),
        date?: string(name='date', example='20230410'),
        fd?: string(name='fd', example='1'),
        idfa?: string(name='idfa', example='0000-0000-0000000'),
        jb?: string(name='jb', example='0'),
        oaid?: string(name='oaid', example='343rUFD834343KJDDFS'),
        py?: string(name='py', example='1'),
        rl?: string(name='rl', example='RISK'),
        rs?: string(name='rs', example='60'),
        zid?: string(name='zid', example='815E045B-4A9E-AA76-BEFF-048C9B9F651A'),
      }
    ](name='riskDetails'),
    riskSumary?: [ 
      {
        date?: string(name='date', example='20230418'),
        riskZidEmuDistinctNew?: string(name='riskZidEmuDistinctNew', example='2'),
      }
    ](name='riskSumary'),
  }(name='data'),
  requestId?: string(name='requestId', example='2343535353DF8984565'),
  success?: boolean(name='success', example='true'),
}

model ListChannelRiskDetailsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListChannelRiskDetailsResponseBody(name='body'),
}

/**
 * @summary  渠道风险明细
 *
 * @param request ListChannelRiskDetailsRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListChannelRiskDetailsResponse
 */
async function listChannelRiskDetailsWithOptions(request: ListChannelRiskDetailsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListChannelRiskDetailsResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.channel)) {
    query['channel'] = request.channel;
  }
  if (!Util.isUnset(request.dataSourceId)) {
    query['dataSourceId'] = request.dataSourceId;
  }
  if (!Util.isUnset(request.end)) {
    query['end'] = request.end;
  }
  if (!Util.isUnset(request.isAllChannel)) {
    query['isAllChannel'] = request.isAllChannel;
  }
  if (!Util.isUnset(request.start)) {
    query['start'] = request.start;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListChannelRiskDetails',
    version = '2022-11-28',
    protocol = 'HTTPS',
    pathname = `/anti/listChannelRiskDetails`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary  渠道风险明细
 *
 * @param request ListChannelRiskDetailsRequest
 * @return ListChannelRiskDetailsResponse
 */
async function listChannelRiskDetails(request: ListChannelRiskDetailsRequest): ListChannelRiskDetailsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listChannelRiskDetailsWithOptions(request, headers, runtime);
}

model ListUninstallDetailRequest {
  dataSourceId?: string(name='dataSourceId', description='This parameter is required.', example='62c792d188ccdf4b7ec1aa38'),
  endDs?: string(name='endDs', description='This parameter is required.', example='20231120'),
  startDs?: string(name='startDs', description='This parameter is required.', example='20231120'),
}

model ListUninstallDetailResponseBody = {
  msg?: string(name='Msg', description='msg'),
  success?: boolean(name='Success', description='success', example='True'),
  code?: long(name='code', description='code', example='200'),
  data?: {
    details?: [ 
      {
        activeDatetime?: string(name='activeDatetime', example='1700278078773'),
        city?: string(name='city', example='阳江市'),
        deviceBrand?: string(name='deviceBrand', description='deviceBrand', example='HONOR'),
        deviceModel?: string(name='deviceModel', description='deviceModel', example='KOZ-AL00'),
        firstActiveDatetime?: string(name='firstActiveDatetime', description='firstActiveDatetime', example='2023-11-12 22:41:46'),
        idfa?: string(name='idfa', description='idfa', example='5ce253a8-2917-44da-a1fe-9d21051f9015'),
        imei?: string(name='imei', description='imei', example='None'),
        installAppVersion?: string(name='installAppVersion', description='installAppVersion', example='23.05.06'),
        installChannel?: string(name='installChannel', description='installChannel', example='umeng'),
        oaid?: string(name='oaid', description='oaid', example='ai357e2b5358797ddc'),
        osVersion?: string(name='osVersion', description='osVersion', example='10'),
        puid?: string(name='puid', description='puid', example='zhangfei'),
        umid?: string(name='umid', example='ai357e2b5358797ddc1857a66deb6b5d14'),
        uninstallCount?: int32(name='uninstallCount', example='3'),
        uninstallDatetime?: string(name='uninstallDatetime', example='20231118'),
        zid?: string(name='zid', description='zid', example='ddc1857a66deb6b5'),
      }
    ](name='details'),
  }(name='data'),
  requestId?: string(name='requestId', description='requestId', example='8797ddc1857a66deb6b5d14'),
}

model ListUninstallDetailResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListUninstallDetailResponseBody(name='body'),
}

/**
 * @summary 卸载明细列表
 *
 * @param request ListUninstallDetailRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListUninstallDetailResponse
 */
async function listUninstallDetailWithOptions(request: ListUninstallDetailRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListUninstallDetailResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.dataSourceId)) {
    query['dataSourceId'] = request.dataSourceId;
  }
  if (!Util.isUnset(request.endDs)) {
    query['endDs'] = request.endDs;
  }
  if (!Util.isUnset(request.startDs)) {
    query['startDs'] = request.startDs;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListUninstallDetail',
    version = '2022-11-28',
    protocol = 'HTTPS',
    pathname = `/uninstall/listUninstallDetail`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 卸载明细列表
 *
 * @param request ListUninstallDetailRequest
 * @return ListUninstallDetailResponse
 */
async function listUninstallDetail(request: ListUninstallDetailRequest): ListUninstallDetailResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listUninstallDetailWithOptions(request, headers, runtime);
}

